import request from '@/utils/request'
import qs from 'qs'
/** *******************        bill-center          ********************/

export function fetchBillInfoList(query) {
  return request({
    url: '/billinfo/list',
    method: 'get',
    params: query,
    paramsSerializer: (query) => {
      return qs.stringify(query, { arrayFormat: 'repeat' })
    }

  })
}

export function fetchBillInfo(id) {
  return request({
    url: `/billinfo/info/${id}`,
    method: 'get'
  })
}

export function updateBillInfo(id, data) {
  return request({
    url: `/billinfo/info/${id}`,
    method: 'put',
    data
  })
}

/** *******************        bill-release          ********************/

export function fetchReleaseList(query) {
  return request({
    url: '/activity/list',
    method: 'get',
    params: query
  })
}

export function fetchRelease(id) {
  return request({
    url: `/activity/info/${id}`,
    method: 'get'
  })
}

export function createRelease(data) {
  return request({
    url: '/activity/info',
    method: 'post',
    data
  })
}

export function updateRelease(id, data) {
  return request({
    url: `/activity/info/${id}`,
    method: 'put',
    data
  })
}

export function deleteRelease(id) {
  return request({
    url: `/activity/info/${id}`,
    method: 'delete'
  })
}

/** *******************        bill-detail          ********************/

export function fetchDetailList(query) {
  return request({
    url: '/activity/carousel/list',
    method: 'get',
    params: query
  })
}

export function fetchList(query) {
  return request({
    url: '/activity/list/carousel',
    method: 'get',
    params: query
  })
}

export function fetchDetail(query) {
  return request({
    url: '/activity/carousel/detail',
    method: 'get',
    params: query
  })
}

/** *******************        bill-share          ********************/

export function fetchShareDetail(shareNum) {
  return request({
    url: `/share/detail/${shareNum}`,
    method: 'get'
  })
}

export function fetchShareSave(data) {
  return request({
    url: '/share/save',
    method: 'post',
    data
  })
}

export function fetchShareList(query) {
  return request({
    url: '/share/list',
    method: 'get',
    params: query
  })
}

/** *******************        bill-index          ********************/

export function indexCount() {
  return request({
    url: `/index/count`,
    method: 'get'
  })
}